home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 010 / bugs.arc / QUIRKS.TXT
Encoding:
Text File  |  1988-02-20  |  31.7 KB  |  671 lines

  1. New items added 02/14/88 to 02/20/88:
  2.  
  3. Part 1 - CALL (Asm) - Don't have label at END statement
  4.          * next to a QB 4 entry indicates that the problem has been
  5.        fixed with the QB 4.00a that is included in BASCOM 6.
  6.      DIM QB 4
  7.      OPEN COM QB 4
  8. Part 2 - Color patches don't affect Hercules
  9. -------------------------------------------------------------------------
  10.  
  11. This file contains information about bugs, quirks, and general points
  12. of interest to programmers working with compiled BASIC. It is divided
  13. into three parts:
  14.  
  15.   Part 1 - Description of bugs, quirks and errors
  16.   Part 2 - General points of interest
  17.   Part 3 - Sample programs
  18.  
  19. If you want to find one of the above quickly, use your text editor to
  20. search for the text shown above. i.e., Search for "Part 1 -".
  21.  
  22. This file is maintained by Mark Novisoff of MicroHelp, Inc. Much of the
  23. information was contributed by members of MicroHelp's BASIC Users Group.
  24. If you have additional information that should be added, please send it
  25. to:
  26.      Mark Novisoff
  27.      MicroHelp, Inc.
  28.      2220 Carlyle Drive
  29.      Marietta GA 30062
  30.      (404) 973-9272
  31.      Compuserve ID 73047,3706 in MSSYS (Microsoft Systems Forum)
  32.  
  33. Part 1 - Description of bugs, quirks and errors
  34.  
  35. Note: * Next to a QB 4 entry indicates that the problem has been
  36.     fixed with the QB 4.00a that is included in BASCOM 6.
  37.  
  38. Command/Error  Compilers       Description
  39. -------------- --------------- --------------------------------------------
  40. $INCLUDE       QB 4            If you have a DEFINT statement in an include
  41.                                file and you wish to use it within subprograms/
  42.                    functions in a module, you must $INCLUDE it
  43.                    within each sub/function structure. If you
  44.                    simply include it in the mainline code, the
  45.                    DEFINT statement is not recognized. However,
  46.                    if you have a statement DEFINT in your mainline
  47.                    code (as opposed to $INCLUDE), it will work ok.
  48. CALL (asm)     QB 4            Effective with QB 4, assembly
  49.                                language subroutines must preserve
  50.                                the SI and DI registers and make
  51.                                sure the direction flag is cleared
  52.                                before returning to BASIC.
  53.                    In addition, you must not have a label name
  54.                    after the END statement in your assembler code.
  55. CALL INIT      QB 2-3          Do not name a precompiled subprogram "INIT".
  56.                                If you do, the compiler will go into never-
  57.                    never land when your user library is loaded.
  58. CALL vs GOSUB  All             If you have many calls to the same
  59.                                asm routine or subprogram, you'll
  60.                                use less memory if you set
  61.                                variables and GOSUB to a routine
  62.                                that performs the CALL instead of
  63.                                having the CALL "in line". CALL is
  64.                                much faster using variables than
  65.                                using "literals".
  66. CALLS          QB 4*           When CALLS (note the "S") is used and you
  67.                                compile with "/D" (debug), the segment of
  68.                    of a string element descriptor does not get
  69.                    passed on the stack. In other words, if you
  70.                    have an assembly language subroutine that
  71.                    uses CALLS, you should not compile with "/d".
  72. CHAIN          QB 4            Unreliable when using DOS 2.x.
  73. CIRCLE         QB 4            The start and end angles must be
  74.                                LESS than 2*pi. Previously they could
  75.                    be less than or equal to.
  76. CLEAR,,Size    QB 3,4          If you receive an out of stack
  77.                                space message. The stack size is
  78.                                not reset between CHAIN'ing but if
  79.                                you CHAIN back to your original
  80.                                program, be sure to skip the CLEAR
  81.                                instruction.
  82. COMMON and     QB 2-4          All statements that use COMMON or variations
  83.   COMMON SHARED                thereon with CHAIN must use parameter lists
  84.                                that match exactly. Best done with $INCLUDE.
  85. COMMON with TYPE
  86.                QB 4            The TYPE statement must appear before
  87.                            the COMMON statement and must appear in
  88.                    all programs that use it. The COMMON
  89.                    statement must contain "AS". See sample
  90.                    program #1 at the end of this file.
  91. Compile to EXE QB 4            QB issues an unusual LINK command in the
  92.                                form of:
  93.                      LINK Prog+YourLib.Lib;
  94.                    This causes LINK to bring the entire
  95.                    library into your program! The solution is
  96.                    to exit QB, and run BC and LINK yourself.
  97. CONST          QB 4            Must be included in all program modules
  98.                                that use the constant. Place in the file
  99.                    at the top, rather than inside SUB's.
  100. DATA           QB 4            When a DATA statement is encountered inside
  101.                                a SUB...END SUB structure, QB moves it
  102.                    into the "mainline" portion of the code when
  103.                    you are in the environment. 
  104. DEFINT         QB 4            See $INCLUDE.
  105. DEF FN         All             Functions are local to the module
  106.                                in which the DEF FN appears. Use
  107.                                QB 4's FUNCTION..END FUNCTION for
  108.                                global functions.
  109. DIM            QB 3            See sample program #4. QB3 apparently has
  110.                                a limit of 123 dynamic arrays.
  111. DIM            QB 4            In order to take advantage of the /AH switch
  112.                                with TYPE..END TYPE records, the record
  113.                    length must be a power of 2 (4,8,16,32, etc.)
  114. DIM            QB 4            Static numeric arrays are stored on the
  115.                                "heap" when you are inside the QB 4
  116.                    environment. BC programs store them in the
  117.                    default DS.
  118. DIM (TYPE)     QB 4            See sample program #1 for dimensioning
  119.                                arrays of TYPE'd variables.
  120. Division       All             Using integer division "\" when an
  121.                                integer result is desired is much
  122.                                faster than normal division "/".
  123. DRAW           QB 2-4          Does not respect the boundaries designated
  124.                                by WINDOW.
  125. ERR            QB 4            Inside the QB 4 environment. If you watch
  126.                                a variable, ERR does not get set properly
  127.                    when an error occurs. See sample program #5.
  128. FIELD          QB 4            We've had a report that if you use array
  129.                                elements for FIELD'ing a Btrieve file, and
  130.                    you don't DIM the string array (i.e., you
  131.                    default to 10 elements) that you can get
  132.                    string space corrupt errors. The solution
  133.                    is always to DIM the arrays.
  134. FILES          QB 3            There is a bug in the QB3-8087 compiler that
  135.                                causes FILES not to work correctly.
  136. FOR/NEXT       QB 4*           If you use a long integer as your loop
  137.                                counter, with a negative STEP, your loop
  138.                    will not execute.
  139. FOR/NEXT       QB 4            If you use an integer for a loop counter,
  140.                                and the top of the loop is 32767 (when
  141.                    STEP is positive) or the bottom of the
  142.                    loop is -32768 (when STEP is negative),
  143.                    you'll get an overflow when inside the QB
  144.                    environment or when compiled with BC using
  145.                    "/d". With BC,if you don't use "/d", the loop 
  146.                    does not stop at the top/bottom - it wraps 
  147.                    around and executes your loop indefinitely.
  148. FRE(-1)        QB 4            If a Quick Library is loaded, this value
  149.                                may return incorrectly. QB 4 seems to
  150.                    forget that the library is loaded and
  151.                    thinks that the space is available. But,
  152.                    QB 4 won't let you use the space for
  153.                    dynamic arrays.
  154. FRE("")        QB 4*           Using BRUN gives approximately 4K more
  155.                                than BCOM. Here is a table showing the
  156.                    difference between compilers for a one
  157.                    line program PRINT FRE(""):
  158.                       
  159.                                BC     BC6
  160.                        BRUN  57280   59912
  161.                        BCOM  61560   61640
  162. FUNCTION       QB 4            Provides global functions for all
  163.                                modules in a program. All that is
  164.                                needed is a DECLARE statement in
  165.                                any module that needs to use the
  166.                                function. In addition, this type
  167.                                of function can be recursive. See DEF FN.
  168. FUNCTION       QB 4            Cannot be used in $INCLUDE files.
  169. HEX$           QB 4            Be careful when using with non-integer
  170.                                values. For example, the output from
  171.                    the two lines shown is "FFFF8002".
  172.                      E&=&H8002
  173.                      PRINT HEX$(E&)
  174. IF..THEN..ELSE QB 3            More than two nestings for ELSE on a single
  175.                                line will not compiler properly.
  176. LIB.EXE        n/a             LIB cannot recognize the name of a library
  177.                                if you precede the library name with a path
  178.                    that contains a hyphen "-". For example, if
  179.                    you enter the following, LIB will fail:
  180.                       LIB Test-Dir\MyLib <Enter>
  181. LINE INPUT     QB 4*           Don't attempt to LINE INPUT directly to a typed
  182.                                variable (using TYPE...END TYPE) that has
  183.                    a period in the name. Rather, LINE INPUT to a
  184.                    temporary variable and then assign it to
  185.                    the TYPE'd variable.
  186. LINK           All             Use the /EXEPACK switch to condense the
  187.                                file. Can be used on any program except
  188.                    programs that are CHAIN'ed to using
  189.                    all compilers except QB 4. All QB 4
  190.                    programs can use this switch. Syntax:
  191.                      LINK /EXE Progname (etc.)
  192. LINK           QB 4            When building a Quick Library, be sure
  193.                                to specify BQLB40 in the library field. Example:
  194.                      LINK /QU ObjMods,Lib,,BQLB40;
  195. LOAD           QB 4            If you receive an "out of memory"
  196.                                error, try breaking your program
  197.                                into logical pieces (using
  198.                                subprograms). Then use COMMON
  199.                                SHARED for all variables that you
  200.                                need in the entire program. The
  201.                                exact same COMMON SHARED
  202.                                declaration must appear in all the
  203.                                modules in the program that need
  204.                                access to the variables.
  205. LOAD            QB 4           If you download a QB 4 program in "fast load"
  206.                                format, many modem transfer protocols
  207.                    pad the file out using a number of
  208.                    CHR$(0)'s. This will cause QB 4 to
  209.                    crash when you attempt to load the program.
  210.                    Use DEBUG to view the file, then write
  211.                    the program to disk after changing the
  212.                    CX register to shorten the length of the
  213.                    file so that the trailing CHR$(0)'s are
  214.                    not included. The other solution is to
  215.                    download this type of file using an ARC
  216.                    program that restores the original length
  217.                    of the file.
  218. ON ERROR        QB 4*          If the first ON ERROR statement in your 
  219.                                program is "ON ERROR GOTO 0", two problems
  220.                    can occur:
  221.                      1. If an error occurs in your program,
  222.                     your system will crash.
  223.                  2. You may get a "Program memory overflow"
  224.                     error from BC 4.
  225.                    The solution is that the first ON ERROR GOTO
  226.                    should not be to line "0".
  227. ON ERROR        QB 4           See "RESUME" for QB 4.
  228. ON ERROR        QB 2-4         Error handler routines must be located
  229.                                outside SUB...END SUB structures. You
  230.                    can RESUME to a line number/label that
  231.                    is outside SUB...END SUB structures 
  232.                    (using /E) or to code inside the sub
  233.                    using plain RESUME or RESUME 
  234.                    NEXT (/X). Much better is to $INCLUDE
  235.                    subroutines that perform error trapping
  236.                    instead of having them in subprograms.
  237.                    This allows the use of RESUME line number/
  238.                    label and avoids the /X.
  239. OPEN COM        QB 4*          If you open the COM port within
  240.                                the environment, then compile to an EXE
  241.                    from within the environment, you get a
  242.                    "far heap corrupt" error.
  243. OPEN COM        QB 4*          If you open a COM port, close the port, then
  244.                                do a SHELL, you cannot reopen the same port.
  245.                    The compiler sets the COM port address
  246.                    (at hex 40:0 through 40:7, depending on the
  247.                    COM port number) to 0 and cannot find the
  248.                    port. The solution is to leave the port
  249.                    open during the SHELL.
  250. OPEN            All            With Novell NetWare, using OPEN on a file that
  251.                                does not exist does not always create the file.
  252.                    Novell has acknowledged the problem but no
  253.                    solution is available as of 12/19/87.
  254. Overflow        All            BASIC uses integer types for all
  255.                                calculations and processes the
  256.                                right side of the equal sign
  257.                                before the left side. To force
  258.                                BASIC to use a different numeric
  259.                                type, place a type identifier on
  260.                                the right of the equal sign.
  261.                                Example: A=Peek(2)+256!*Peek(3)
  262. PRINT #         QB 4           In order to print a blank line using QB 4,
  263.                                use the syntax:
  264.                      PRINT #, 
  265.                    Note the absence of the null string after
  266.                    the comma. We've had an unconfirmed report
  267.                    that if the print buffer is filled, using
  268.                    the null string causes characters to be
  269.                    dropped.
  270. PRINT USING     QB 4           With previous compilers, you could place TAB
  271.                                statements, variable names, or most anything
  272.                    else between PRINT and USING. With QB 4, 
  273.                    nothing should come between PRINT and USING.
  274. REDIM           QB 3           If you have a subprogram that REDIM's arrays,
  275.                                and you get a "string space corrupt" message
  276.                    after calling the subprogram several times,
  277.                    try using ERASE on the array before you do
  278.                    the REDIM.
  279. RESUME          All            If you always use RESUME
  280.                                <linenumber> or RESUME <label> you
  281.                                can use the "/e" switch instead of
  282.                                "/x". Makes programs smaller!
  283.                                This is not practical for
  284.                                subprograms, so error trapping is
  285.                                better handled in mainline code.
  286.                    See ON ERROR.
  287. RESUME          QB 4           If you compile to an EXE from
  288.                                inside the environment, a "/X" is
  289.                                generated by QB even though it's
  290.                                not needed. Be sure to recompile
  291.                                with "/E" outside of the
  292.                                environment if your program
  293.                                doesn't need "/X".
  294. RUN             QB 4*          See sample program #3. If you use RUN in a
  295.                                program that has soft key definitions, the
  296.                    system will crash if the program was compiled
  297.                    with BC. It will work OK in the environment.
  298. SADD            QB 4           When using SADD-188 for Btrieve,
  299.                                be sure to make this calculation
  300.                                EACH TIME you are going to CALL
  301.                                Btrieve. This is because QB 4 can
  302.                                move the FIELD'ed strings around
  303.                                in memory.
  304. SAVE            QB 4           If you edit a new program and save it,
  305.                                QB defaults to "fast load" format. The
  306.                    file cannot be handled by a text editor.
  307.                    Fix by using "save as".
  308. SELECT CASE     QB 3           Much less forgiving than QB 4. For example,
  309.                                when using a string, you can't say:
  310.                      CASE CHR$(3)
  311.                    However, you can embed the literal character
  312.                    with an ASCII value of 3 in quotes!     
  313. SELECT CASE     QB 4           You cannot have a line number or label 
  314.                                between the SELECT CASE and the first CASE.
  315. SELECT CASE     QB 4*          Doesn't allow periods in variable names that
  316.                                are "plain" variables. If using a TYPE'd
  317.                    record element (which does indeed use periods),
  318.                    QB 4 will accept that with no problem.
  319. SIGNAL          QB 4*          BC 6 - Similar to event trapping, but for OS/2.
  320. SLEEP           QB 4*          BC 6 - Suspends the program, waiting for a
  321.                                user-defined event.
  322. SOUND           QB 3/87        Generates error 6 in all forms when the
  323.                                emulator is used on non-87 machines.
  324. STATIC          QB 4           When used with a subprogram, makes
  325.                                the subprogram faster, since local
  326.                                variables are not initialized on
  327.                                each call.
  328. String Space    QB 4           Drops you out to DOS without saving
  329.   Corrupt                      your program. The solution is to save
  330.                                often!
  331. STRING$         All            A$=String$(5,65) takes less code than
  332.                                A$=String$(5,"A") and both are smaller
  333.                    than A$="AAAAA".
  334. SUB...END SUB   QB 4           Cannot be used in $INCLUDE files. Cannot
  335.                                have the same name as a variable (regardless
  336.                    of the variable type).
  337. TYPE..END TYPE  QB 4           There has been an unverified problem reported
  338.                                in QB when the record length is an odd number.
  339.                    A "FAR HEAP CORRUPT" error is generated.
  340.                    The problem reportedly occurs when the record
  341.                    length is an odd number of bytes. It does not
  342.                    seem to appear in BC, only QB. If you have
  343.                    an unusual, otherwise unexplained problem,
  344.                    try changing the record length to an even number.
  345. TYPE..END TYPE  QB 4           See "DIM" for QB 4.
  346. TYPE..END TYPE
  347.  (with COMMON)  QB 4           See COMMON (with TYPE) and sample program #1.
  348. UBOUND          QB 2-3         If you ERASE an array, UBOUND will return the
  349.                                upper bound of the array BEFORE it was erased.
  350.                    This works OK in QB 4.
  351. VAL             QB 4           Generates an error (rather than value of 0)
  352.                                when "%" is the first character in the string.
  353. WINDOW          QB 2-4         Does not affect DRAW statements.
  354. ----------------------------------------------------------------------------
  355. Part 2 - General points of interest
  356. ----------------------------------------------------------------------------
  357. Long integers with QB 4
  358.  
  359. When you have a long integer array with two dimensions, BC may not handle
  360. the zeroth elements correctly on machines without a math coprocessor
  361. unless you use the "/d" switch. QB handles the situation OK because "debug"
  362. is always on when working in the environment.
  363.  
  364. Secondly, if you dimension the same two-dimensional array using a variable
  365. name instead of a numeric constant, BC may not handle your array at all! The
  366. fix is to use only constant numbers in dimensioning the array. Another fix
  367. that DOES work with dynamic arrays, is to use the /R switch when compiling.
  368. ----------------------------------------------------------------------------
  369. More on long integers
  370.  
  371. If you pass a long integer array to a subprogram, QB will work OK, but
  372. BC does not. See Sample Program #2.
  373. ----------------------------------------------------------------------------
  374. LIB environment variable
  375.  
  376. If you set the LIB environment variable, you will find that QB, BC, BUILDLIB
  377. and LINK will all search the specified path whenever a User Lib, Quick Lib or
  378. LINK lib is needed. The syntax is similar to the DOS Path syntax:
  379.  
  380.   SET LIB=C:\Libs;C:\DOS;C:\QB
  381. ----------------------------------------------------------------------------
  382. Undocumented switches in QuickBASIC 3
  383.  
  384. QB ProgramName/F compiles the specified program to an EXE file without 
  385. starting up the QB editor.
  386.  
  387. QB ProgramName/Z tells QB to load and execute ProgramName and exit to DOS
  388. when the program ends.
  389. ----------------------------------------------------------------------------
  390. Response files
  391.  
  392. BUILDLIB and LINK both accept input from response files. This is exactly the
  393. same as redirection of input, but the programs will continue running when
  394. the end of the file is reached prematurely. Example:
  395.  
  396. Response file contains:
  397.   Prog1+Prog2+Prog3+
  398.   Prog4+Prog5+Prog6 Rem Don't include ANY additional blank lines
  399.   
  400. Buildlib batch file contains:
  401.   Buildlib @Response.Fil,MyLib.Exe;
  402.   
  403. Buildlib will take its input from the response file because the "@" sign
  404. tells it to!      
  405. ----------------------------------------------------------------------------
  406. BUILDLIB and "too many segments" error
  407.  
  408. Where "nnnn" is a number from 1 to 1024, use:
  409.  
  410.    BUILDLIB /SEG:nnnn
  411.  
  412. That increases (or decreases) the number of allowable segments. Default=255.
  413. ----------------------------------------------------------------------------
  414. Patching QB 4 menu and help colors.
  415.  
  416. This color table in this file was uploaded by Dave Engfer to the 
  417. MicroHelp Basic Users Group BBS. Note that if you are running QB on a 
  418. Hercules board, these patches won't have any effect.
  419.  
  420. If you don't like the colors that QB 4.0 uses, you can patch it to show
  421. the colors you want. In order to effect your patches, do the following:
  422.  
  423.   Make a backup copy of QB.EXE.
  424.   REN QB.EXE QB <Enter>
  425.   DEBUG QB <Enter>
  426.   R <Enter>
  427.     
  428. At this point, debug will show you the current register settings and
  429. the current instruction. Something like this:
  430.  
  431. -r
  432. AX=0000  BX=0003  CX=82A0 etc.
  433. DS=xxxx  ES=xxxx  SS=xxxx etc.
  434. xxxx:0100 RD       DEC     BP
  435.  
  436. The "xxxx" is the current code segment. On my machine, the value is 2A28.
  437. The color table that QB uses is located near the end of the QB program, 
  438. specifically 3 full segments higher than "xxxx". That means you will
  439. need to add 3000 hex to the number of the segment shown. In my case,
  440. I would patch segment 5A28. Note that adding 3 to the first of the four
  441. hex numbers does the trick.
  442.  
  443. Now, with the higher segment address in mind, display the existing color
  444. table. Remember, the segment on your machine is most likely different
  445. from mine, but the offset "5B6F" should be the same. On my system:
  446.  
  447.    d 5A28:5B6F <Enter>
  448.  
  449. gives the following table (on my system, "xxxx" is 5A28):
  450.    
  451. xxxx:5B60                                              34
  452. xxxx:5B70 30 4F 34 30 38 4F 47 34-38 70 71 74 07 47 0A 30
  453. xxxx:5B80 3F 17 4A 00 07 70 70 0F-7F 70 78 0F 07 7F 70 70 etc.
  454.  
  455. Below you'll find a table of the colors and what Dave thinks they represent.
  456. Note that some are marked "unknown". Dave suspects they may be related to
  457. rodents.
  458.  
  459. You can change your copy of QB to display the various colors by changing
  460. the values in the table. The formula for determining color is the same as
  461. in Mach 2: Attribute=Background*16+Foreground.
  462.  
  463. As an example, suppose you want to change the "top line highlight" to
  464. red on green (XMAS is only a month away!). The color attribute we want
  465. (in HEX for debug) is 2*16+4 or 36 decimal or 24 HEX.
  466.  
  467. So, to patch that color:
  468.  
  469. -e xxxx:5B71 24 <Enter>
  470. -w <Enter>
  471. -q <Enter>
  472. REN QB QB.EXE
  473.  
  474. Now, when you hold the Alt key (without pressing anything else), "File"
  475. appears in red on green.
  476.  
  477.      Original Color        Addr  Byte   Effect        
  478.      ---------------------------------------------------------------------
  479.      Red on Cyan           5B6F   34    The outline for the pulldown boxes
  480.      Black on Cyan         5B70   30    The Color for the top line
  481.      Bright White on Red   5B71   4F    Top line Highlight (e.i. press 'Atl'
  482.                                         and the option will highlight)
  483.      Red on Cyan           5B72   34    Top line first letter highlight
  484.      Black on Cyan         5B73   30   *Pulldown box text and background - 1
  485.      Bright Black on Cyan  5B74   38   *Pulldown box text and background - 2 
  486.      Bright White on Red   5B75   4F   *Pulldown box highlight line - 1
  487.      White on Red          5B76   47   *Pulldown box highlight line - 2
  488.      Red on Cyan           5B77   34   *Pulldown box first letters - 1
  489.      Bright Black on Cyan  5B78   38   *Pulldown box first letters - 2
  490.      Black on White        5B79   70    Frame around the Help box- Shft F1
  491.      Blue on white         5B7A   71    Help box selection area- Shft F1
  492.      Red on White          5B7B   74    Help box first letter highlight- F1
  493.      White on Black        5B7C   07    Normal text (Default)
  494.      White on Red          5B7D   47    Breakpoint line (Default)
  495.      Bright Green on Black 5B7E   0A    Current line (Default)
  496.      Black on Cyan         5B7F   30    Bottom line prompt text
  497.      Bright White on Cyan  5B80   3F    Microsoft Copyright Notice  
  498.  
  499. Notes-     
  500.      * - Microsoft uses two different color bytes for the pulldown boxes.
  501.      1 - This byte seems to be used for options with a highlight letter.
  502.      2 - This byte seens to be used for options without a highlight letter.
  503. ----------------------------------------------------------------------------
  504. DTR patch (QB4 BCOM)
  505.  
  506. See instructions on patching colors (above) for patching BCOM40.LIB so that
  507. standalone programs do not drop DTR during a SHELL. A side effect is that
  508. after closing the COM file, DTR remains up.
  509.  
  510. ** Note ** 
  511.   The success or failure of this patch has not been confirmed. At this time,
  512.   it has simply been reported by a user. If anyone has any feedback, I'd
  513.   sure appreciate it.
  514.   
  515. Patch the 1st segment above the default DS (add &H1000 to default). All
  516. values are in HEX.
  517.  
  518.    Address  Old Value  New Value
  519.    -------  ---------  ---------
  520.     2A42       32         B0
  521.     2A43       C0         01
  522.     2D0C       32         B0
  523.     2D0D       C0         B1
  524.  
  525. ----------------------------------------------------------------------------
  526. Entering unusual ASCII values.
  527.  
  528. If you're not familiar with WordStar, you may not know that you can enter
  529. unusual characters into the QB4 editor by doing the following:
  530.  
  531.   Hold the Ctrl key and press "P" once (nothing will happen).
  532.   Release the Ctrl key.
  533.   Press and hold the Alt key.
  534.   Using the keypad number keys (not the keys on the top of the keyboard),
  535.     enter the ASCII value for the key you want. For example, the 'Esc' key
  536.     is ASCII 27, so press the "2", then the "7".
  537.   Release the Alt key, and your special character will appear!  
  538. ----------------------------------------------------------------------------
  539. Part 3 - Sample programs
  540. ----------------------------------------------------------------------------
  541. Sample program #1. How to use COMMON with TYPE'd variables.
  542.  
  543.        ' Prog1.bas
  544.  
  545.          TYPE Namerec
  546.            LastName AS STRING * 20
  547.            FirstName AS STRING *15
  548.          END TYPE
  549.          COMMON Filename() AS Namerec
  550.          DIM Filename(5) AS Namerec
  551.          Filename(1).LastName="Novisoff"
  552.          Filename(1).FirstName="Mark"
  553.          CHAIN "Prog2"
  554.  
  555.        ' Prog2.bas
  556.        
  557.          TYPE Namerec
  558.            LastName AS STRING * 20
  559.            FirstName AS STRING * 15
  560.          END TYPE
  561.          COMMON Filename() AS Namerec
  562.          PRINT Filename(1).LastName, Filename(1).FirstName
  563.  
  564. ----------------------------------------------------------------------------
  565. Sample program #2. Demonstrates problem with long integers in subprograms.
  566.  
  567. DECLARE SUB TestLong (LongArray&())
  568. 'Demonstration to show difference between return values of long integers
  569.  
  570. 'Returns desired value if compiled in the environment, but not if compiled
  571. 'by BC.
  572.  
  573. 'This fault only appears if the code is in a subprogram and compiled with BC
  574. REM $Dynamic
  575. DIM LongArray&(10)
  576. DIM MainArray%(10)
  577.  
  578. CLS
  579. LongArray&(1) = 100
  580. MainArray%(1) = 10
  581.  
  582. FOR x% = 1 TO 2
  583.     LongArray&(1) = MainArray%(1) + LongArray&(1)
  584.     ' Note: if you change the above into the following two lines, this part
  585.     '       of the program will run correctly.
  586.     'Temp& = MainArray%(1)
  587.     'LongArray&(1) = Temp& + LongArray&(1)
  588. NEXT
  589.  
  590. PRINT "TestLong should = 120"
  591. PRINT "Long Array from MAIN = "; LongArray&(1)
  592. PRINT : PRINT "Same code in a subprogram"
  593. PRINT
  594.  
  595. CALL TestLong(LongArray&())
  596.  
  597. PRINT "TestLong should return 120"
  598. PRINT "Long Array from TestLong sub = "; LongArray&(1)
  599.  
  600. SUB TestLong (LongArray&())
  601. DIM IntArray%(10)
  602.  
  603. LongArray&(1) = 100
  604. IntArray%(1) = 10
  605.  
  606. FOR x% = 1 TO 2
  607.     LongArray&(1) = IntArray%(1) + LongArray&(1)
  608.     ' Note: if you change the above into the following two lines, this part
  609.     '       of the program will run correctly.
  610.     'Temp& = IntArray%(1)
  611.     'LongArray&(1) = Temp& + LongArray&(1)
  612. NEXT
  613. END SUB
  614.  
  615. ----------------------------------------------------------------------------
  616. Sample program #3. Demonstrates problem when "RUN" is used in a program
  617. that contains soft key definitions. Compile with BC in QB 4.
  618. * Note: This problem has been fixed in BC 6.
  619.  
  620. KEY 1, "Anything" + CHR$(13)    ' Previous Quirks.Txt had "RUN"
  621. KEY 2, "END" + CHR$(13)
  622. PRINT "If you compiled with BC.EXE, RUN will crash your program"
  623. INPUT "(F1=RUN  F2=END)  ", yn$
  624. IF yn$ = "Anything" THEN RUN
  625. END
  626. ----------------------------------------------------------------------------
  627. Sample program #4. Demonstrates the limit on dynamic numeric
  628. arrays in QB 3.  This program generates a program called
  629. ARRAY.BAS. Compile ARRAY.BAS with the "/d" switch, LINK it and
  630. RUN it. The sole function of ARRAY.BAS is to generate arrays.
  631. Regardless of the value of I%, and regardless if you use "#",
  632. "%" or "!" as the array type, the program gives an "Out of
  633. memory" error when the 124th array is DIMmed.
  634.  
  635. OPEN "O",#1,"ARRAY.BAS"
  636. PRINT #1,"I%=1"
  637. FOR J=1 TO 126
  638.   L=L+10:PRINT #1,MID$(STR$(L),2);" DIM A";MID$(STR$(J),2);"#(I%):PRINT FRE(-1)"
  639. NEXT 
  640. CLOSE
  641. END
  642. ----------------------------------------------------------------------------
  643. Sample program #5. Demonstrates that the ERR variable does not get set
  644. when you "watch" a variable in a subprogram inside the QB 4 environment.
  645.  
  646. Load this program into the QB 4 environment. Alt-V to view the sub
  647. "CheckFSpec". Alt-D <Enter> to watch any variable, then step through
  648. the program using F8. When you get to the ERRORHANDLER routine, watch
  649. ERR.
  650.  
  651. DECLARE SUB CheckFSpec (FlName$)
  652. COMMON SHARED ErrCode%
  653. ErrCode% = 0
  654. a$ = "c:\quickey\data\tape2.000"
  655. CALL CheckFSpec(a$)
  656. CLOSE
  657. END
  658. ERRORHANDLER:
  659. IF ErrCode% = 0 OR ERR <> 0 THEN ErrCode% = ERR
  660. RESUME NEXT
  661. SUB CheckFSpec (FlName$) STATIC
  662. ON ERROR GOTO ERRORHANDLER
  663. OPEN FlName$ FOR INPUT AS #1
  664. ON ERROR GOTO 0
  665. IF ErrCode% = 0 THEN
  666.     PRINT "Opened "; FlName$; " successfully."
  667. ELSE
  668.     PRINT "Error"; ErrCode%; " attempting to open "; FlName$; "."
  669. END IF
  670. END SUB
  671.